<script setup lang="ts">
import {reactive, ref} from "vue";
import {countDeviceNum, countUserNum} from "@/api";
import CountUp from "@/components/count-up";
import {ElMessage} from "element-plus"

const duration = ref(2);
const state = reactive({
  userNumb: 0,
  monthIncrease: 0,
  dayIncrease: 0,
});


const getData = () => {
  countUserNum().then((res) => {
    if (res.success) {
      state.userNumb = res.data.userNumb;
      state.monthIncrease = res.data.monthIncrease;
      state.dayIncrease = res.data.dayIncrease;
    } else {
      ElMessage.error(res.msg)
    }
  }).catch(err => {
    ElMessage.error(err)
  });

};
getData();
</script>

<template>
  <ul class="user_Overview flex">
    <li class="user_Overview-item" style="color: #00fdfa">
      <dv-border-box-10 class="user_Overview_nums">
        <CountUp :endVal="state.userNumb" :duration="duration"/>
      </dv-border-box-10>
      <p>用户总数量</p>
    </li>
    <li class="user_Overview-item" style="color: #e3b337">
      <dv-border-box-10 class="user_Overview_nums">
        <CountUp :endVal="state.monthIncrease" :duration="duration"/>
      </dv-border-box-10>
      <p>本月新增量</p>
    </li>
    <li class="user_Overview-item" style="color: #0ac622">
      <dv-border-box-10 class="user_Overview_nums">
                <CountUp :endVal="state.dayIncrease" :duration="duration" />
      </dv-border-box-10>

      <p>日新增量</p>
    </li>
  </ul>
</template>

<style scoped lang="scss">
.left-top {
  width: 100%;
  height: 100%;
}

.user_Overview {
  padding: 40px 20px 10px 20px;

  li {
    flex: 1;
    font-size: 16px;
    font-weight: bolder;
    .countup-wrap{
      font-size: 32px;
    }
    p {
      text-align: center;
      height: 16px;
      font-size: 20px;

    }

    .user_Overview_nums {
      width: 100px;
      height: 100px;
      text-align: center;
      line-height: 100px;
      font-size: 22px;
      margin: 50px auto 30px;
      background-size: cover;
      background-position: center center;
      position: relative;

      &::before {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
      }

      &.bgdonghua::before {
        animation: rotating 14s linear infinite;
      }
    }



    .laramnum {
      &::before {
        background-image: url("@/assets/img/left_top_hong.png");
      }
    }
  }
}

.border {
  border-width: 0px !important;
}
</style>
